#ifndef _CONF_READER_H_
#define _CONF_READER_H_

#include <unordered_map>    //用于存放配置文件的key value
#include <string>
#define CONF_FILEPATH "../chat_server.conf"  //配置文件路径
class conf_reader{
public:

    static conf_reader * reader;    //cpp文件中去初始化
    //提供一个全局访问点
    static conf_reader * get_conf_reader_instance(){
        if(reader==nullptr){
            reader=new conf_reader();
            
            static for_conf_reader just_for_delete;
        }
        return reader;
    }
//提供一个内部类，用于完成reader的释放
class for_conf_reader{
public:
    ~for_conf_reader(){
        //在析构函数中释放掉对应的东西
        if(reader){
            delete reader;
            reader=nullptr;
        }
    }
    
};
    bool get_file_to_read(const char * file);
    const char *get_value_from_key(const char *key,const char * default_value);
private:
    conf_reader();
    conf_reader(const conf_reader & )=delete;
    conf_reader & operator=(const conf_reader &)=delete;
    std::unordered_map<std::string,std::string> conf_data;

};


#endif